<template>
	<view style="min-height: 100.1vh">
		<!-- 搜索 -->
		<view class="searchBox flex">
			<u-search v-model="searchVal" :showAction="true" actionText="搜索" bgColor="#fff" height="60rpx"
				borderColor="#ccc" :clearabled="true" placeholder="请输入医生姓名/职位/所属医院" placeholderColor="#ccc"
				@custom="custom"></u-search>
		</view>
		<doctorList ref="doctorList"></doctorList>
	</view>
</template>

<script>
	import {
		doctorList
	} from '../../components/doctorList.vue'
	import {
		getDoctorListApi,
		apprenticeshipApi
	} from '../../common/API/doctorApi.js'
	export default {
		components: {
			doctorList
		},
		data() {
			return {
				searchVal: '',
				doctorListSearch: [],
				pageNum: 1,
				total: 0,
				pageSize: 10
			}
		},
		methods: {
			async custom() {
				this.doctorListSearch = []
				this.pageNum = 1
				this.listDoctor()
			},
			async listDoctor(){
				let res = await getDoctorListApi({
					pageNum: this.pageNum,
					pageSize: this.pageSize,
					queryParam: this.searchVal
				})
				if (res.status == 200) {
					console.log('查询', JSON.stringify(res))
					this.total = res.data.total
					this.doctorListSearch = this.doctorListSearch.concat(res.data.records)
					this.$refs.doctorList.changeDoctorLists(this.doctorListSearch)
				}
			}
		},
		
		onReachBottom() {
			console.log('上拉刷新')
			if (this.doctorListSearch.length >= this.total) {
				return uni.$showMsg('已经到底了')
			}
			this.pageNum = this.pageNum + 1
			this.listDoctor()
		},
		onLoad() {
			this.listDoctor()
		}
	}
</script>

<style scoped lang="scss">
	.searchBox {
		background: #fff;
		height: 80rpx;
		padding: 20rpx 30rpx;
		margin-bottom: 20rpx;

		/deep/ .u-search__action {
			color: #00B4C7;
		}
	}
</style>